package com.lyy.photovoltaic.controller;

import com.alibaba.fastjson.JSONObject;
import com.lyy.photovoltaic.common.vo.ResultVO;
import com.lyy.photovoltaic.mapper.OrdersMapper;
import com.lyy.photovoltaic.service.OrdersService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/orders")
@Api(value = "用户订单接口", tags = "订单管理")
public class OrdersController {
    @Autowired
    OrdersService ordersService;
    @PostMapping(value = "/add")
    public ResultVO addUserCart(@RequestBody JSONObject jsonObject) {
        ResultVO resultVO = ordersService.addOrders(jsonObject);
        return resultVO;
    }
    @GetMapping(value = "/{uId}")
    @ApiImplicitParam(dataType = "string", name = "uId", value = "根据用户id查询相关历史订单", required = true)
    public ResultVO findOrders(@PathVariable("uId") String uId) {
        ResultVO resultVO = ordersService.findOrders(uId);
        return resultVO;
    }
    @PutMapping(value = "/{orderId}")
    @ApiImplicitParam(dataType = "string", name = "orderId", value = "根据订单id修改订单信息", required = true)
    public ResultVO UpdateOrders(@PathVariable("orderId") String orderId,@RequestBody JSONObject jsonObject) {
        ResultVO resultVO = ordersService.UpdateOrders(orderId,jsonObject);
        return resultVO;
    }
    @GetMapping(value = "/unProcessOrders")
    public ResultVO unProcessOrders() {
        ResultVO resultVO = ordersService.unProcessOrders();
        return resultVO;
    }
    @GetMapping(value = "/historicalOrders")
    public ResultVO historicalOrders() {
        ResultVO resultVO = ordersService.historicalOrders();
        return resultVO;
    }
    @GetMapping(value = "/dailyOrders")
    public ResultVO dailyOrders() {
        ResultVO resultVO = ordersService.dailyOrders();
        return resultVO;
    }
    @PutMapping(value = "/logicDelete/{orderId}")
    @ApiImplicitParam(dataType = "string", name = "orderId", value = "根据订单id逻辑删除相关历史订单", required = true)
    public ResultVO logicDeleteOrders(@PathVariable("orderId") String orderId) {
        ResultVO resultVO = ordersService.logicDeleteOrders(orderId);
        return resultVO;
    }
}
